<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加合同页面</title>
	<link rel="stylesheet" type="text/css" href="../Styles/admin-all.css" />
    <link rel="stylesheet" type="text/css" href="../Styles/base.css" />
    <link rel="stylesheet" type="text/css" href="../Styles/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
	<link rel="stylesheet" type="text/css" href="../Styles/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css" />
    <script type="text/javascript" src="../Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="../Styles/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../Styles\laypage\laypage.js"></script>
    <script language="javascript" type="text/javascript" src="../Styles/My97DatePicker/WdatePicker.js"></script>
    <link href="../Styles/My97DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    	#contract{
    		width: 80%;
    		height: 60%;
    		margin: auto;
    		margin-top: 30px;
    	}
    </style>
</head>
<body>


<div id="contract">
	<form action="../showCon/addCon">
		<table class="table" border="#cccccc solid 1px";>
			<thead>
				<tr><th><img alt="" src=""><span style="font-size: 20px"><img alt="" src="../img/add.png">人事合同信息发布</span></th><th style="float: right;"><< <a href="showContract.jsp">返回上一级</a></th></tr>
			</thead>
			<tbody>
				<tr><td class="TableContent" width="10%" style="border-right:#cccccc solid 1px;"> 单位员工：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
				<td width="80%"><input type="text" name="user" id="user" style="background-color:#F5F5F5;color:#006600;" value="" readonly="">
				<input type="hidden" name="userid" id="userid" value=""><a href="javascript:void(0)" id="adduname">+选择人员</a>
				</td></tr>
				
				<tr><td style="border-right:#cccccc solid 1px;">合同编号：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
				<td class="TableData"><input type="text" name="number" class="BigInput" id="con_num" size="40" value="" readonly=""></td>
				</tr>
				
				<tr><td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 合同类型：</td>
				<td class="TableData">
					<select name="type" class="BigStatic">
						<option value="0" selected="selected">请选择类型</option>
						<option value="劳务合同">劳务合同</option>
						<option value="保密合同">保密合同</option>
						<option value="其它">其它</option>			
					</select>
				</td></tr>
				
				<tr><td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 合同状态：</td>
				<td class="TableData">
      				<select name="ckey" class="BigStatic">
						<option value="0" selected="selected">请选择状态</option>
						<option value="试用期">试用期</option>
						<option value="己转证">己转证</option>
						<option value="己解除">己解除</option>			
					</select>
				</td></tr>
				
				<tr><td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 合同签订日期：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
				<td class="TableData"><input class="BigInput" type="text" name="signdate" style="width:168px;" size="20" onclick="WdatePicker({skin:'ext',dateFmt:'yyyy-MM-dd',minDate:'2008-03-08',maxDate:'2100-03-10'})"></td></tr>
				
				<tr>
      				<td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 试用生效日期：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
     				<td class="TableData"><input class="BigInput" type="text" name="testdate" style="width:168px;" size="20" onclick="WdatePicker({skin:'ext',dateFmt:'yyyy-MM-dd',minDate:'2008-03-08',maxDate:'2100-03-10'})"></td>
    			</tr>
				
				<tr>
      				<td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 试用天数：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
      				<td class="TableData"><input type="text" name="testday" class="BigInput" size="15" value="" onkeyup="value=value.replace(/[^0-9^.]/g,'');"> 天</td>
    			</tr>
				
				<tr>
      				<td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 试用到期日期：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
      				<td class="TableData"><input class="BigInput" type="text" name="testenddate" style="width:168px;" size="20" onclick="WdatePicker({skin:'ext',dateFmt:'yyyy-MM-dd',minDate:'2008-03-08',maxDate:'2100-03-10'})"></td>
      			</tr>
				
				<tr>
      				<td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 签约次数：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
      				<td class="TableData"><input type="text" name="signnum" class="BigInput" size="15" value="" onkeyup="value=value.replace(/[^0-9^.]/g,'');"> 次</td>
    			</tr>
				
				<tr>
      				<td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 合同到期日期：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
      				<td class="TableData"><input class="BigInput" type="text" name="signenddate" style="width:168px;" size="20" onclick="WdatePicker({skin:'ext',dateFmt:'yyyy-MM-dd',minDate:'2008-03-08',maxDate:'2100-03-10'})"></td>
      		    </tr>
				
				<tr>
      				<td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;"> 附件文档：</td>
      				<td class="TableData"><input type="text" name="appendix" id="myfile" class="BigInput" style="width:180px;height:22px;line-height:22px;font-size:14px;" value="">
      				<a href="javascript:void(0)" id="sc">+附件上传</a></td>
    			</tr>
    			
    			<tr>
    				<td nowrap="" class="TableContent" style="border-right:#cccccc solid 1px;line-height: 180px;">备注：<font color="#FF0000" title="打*号表示为必填">(*)</font></td>
    				<td><textarea name="replyContent" style="width: 60%;height: 200px"></textarea></td>
    			</tr>
			</tbody>
			<tfoot>
				<tr align="center" class="TableControl">
					<td colspan="2" nowrap=""><input type="submit" value="保存" class="btn btn-primary" id="save"></td>
	 			</tr>
			</tfoot>
		</table>
	</form>
	
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel">
						显示员工姓名表单
					</h4>
				</div>
				<div class="modal-body">
					<form action="">
						<input type="hidden" value="" class="tr_id" name="hid"/>
						<table class="table table-hover">
							<thead>
					        	<tr class="info"><th>显示部门名称</th><th>显示员工名称</th></tr>
					        </thead>
					        <tbody id="tb">
					        	<tr><td id="tb1" class='error'></td><td id="tb2"></td></tr>			
					        </tbody>
					        							
						</table>
					</form>
				</div>
				<div class="modal-footer">  
	                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>  
	                <button type="button" class="btn btn-primary" id="btn1">确定</button>  
	            </div> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
	
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel">
						附件上传页面
					</h4>
				</div>
				<form action="" enctype="multipart/form-data">
				<div class="modal-body">
					
					<input type="file" name="photo" id="word"/>
				
				</div>
				<div class="modal-footer">  
	                 <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
	                 <button type="button" class="btn btn-primary" id="btn1">上传</button> 
	            </div>
	            </form> 
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
</div>

<script type="text/javascript">

$(function(){
	
	//点击出发上传文件的事件
	$(document).on('click','#sc',function(){
		$("#upload").modal("show");
	});
	
	//上传按钮的点击事件
	$(document).on('click','#btn1',function(){
		var formData = new FormData();
        formData.append("photo", document.getElementById("word").files[0]);
		$.ajax({
			url:"../showCon/upload",
			type:"post",
			data: formData,
            /**
            *必须false才会自动加上正确的Content-Type
            */
            contentType: false,
            /**
            * 必须false才会避开jQuery对 formdata 的默认处理
            * XMLHttpRequest会对 formdata 进行正确的处理
            */
            processData: false,
			
			success:function(result){
				console.log(result);
				$("#upload").modal("hide");
				$("#myfile").val(result.fileName);
			}
		})
	});
	
	 var nowDate = new Date();
	 var year = nowDate.getFullYear();
	 var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
	 var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
	 var hours = nowDate.getHours() < 10 ? "0" + nowDate.getHours() : nowDate.getHours();
	 var seconds = nowDate.getSeconds() < 10 ? "0" + nowDate.getSeconds() : nowDate.getSeconds();
	 var minutes = nowDate.getMinutes() < 10 ? "0" + nowDate.getMinutes() : nowDate.getMinutes();
	 var dateStr = "" + year +  month +  day + hours + minutes + seconds;
	//获取合同编号
	console.log(dateStr);
	$("#con_num").val(dateStr);
	
	//点击事件，显示部门名称
	$(document).on('click','#adduname',function(){
		$.ajax({
			url:"../showCon/findSec",
			type:"post",
			dataType:"json",
			
			success:function(result){
				console.log(result.sections);
				$("#myModal").modal("show");
				$("#tb1").html("");
   			 	$.each(result.sections,function(inx,ele){
   			 		$("#tb1").append(
							"<ul><li><a href='javascript:void(0)' id='uname'>"+ele.deptname+"</a><input type='hidden' value='"+ele.seorid+"' id='hid'/></li></ul>"
   			 				/* "<tr><td class='warning' id='deptname'><a href='javascript:void(0)' id='uname'>"+ele.deptname+"</a></td><td></td></tr>" */
					 )
   			 	})
			}
		})
		
	});
	
	//点击事件，显示部门成员信息
	$(document).on('click','#uname',function(){
		var seorid=$(this).siblings("#hid").val();
		console.log(seorid);
		$.ajax({
			url:"../showCon/findUser",
			type:"post",
			data:{"seorid":seorid},
			dataType:"json",
			
			success:function(result){
				console.log(result.users);
				
				$("#tb2").html("");
   			 	$.each(result.users,function(inx,ele){
   			 		$("#tb2").append(
							"<ul><li><input type='radio' name='m' value='"+ele.uname+"'/><a href='javascript:void(0)' id='uname'>"+ele.uname+"</a></li></ul>"
					 )
   			 	})
			}
		})
		
	});
	
	//弹出层的确定按钮的点击时间
	$(document).on('click','#btn1',function(){
		var uname=$("input[type='radio']:checked").val();
		console.log(uname);
		$("#myModal").modal("hide");
		$.ajax({
			url:"../showCon/dec",
			type:"post",
			data:{"uname":uname},
			dataType:"json",
			
			success:function(result){
				console.log(result.contract);
				if(result.contract!=null){
					$("#user").val();
				}else{
					$("#user").val(uname);
				}
			}
		})
		
	});
	
	//保存的点击事件
	/* $(document).on('click','#save',function(){
		
	}); */
	
})


</script>
</body>
</html>